<!--排污许可证 dspInfo-->
<template>
    <Layout>
        <Form ref="queryForm" :model="dataToQuery" :label-width="120">
            <Row v-show="!switchFlag" class="query-form" >
                <Col span="8">
                    <FormItem label="企业名称：" prop="order">
                        <cascader-dom class="query-form-el" ref='queryOrgCascader' @setOrgInfo='setQueryCompanyId' :orgTree="true"
                              :currentOrgId="dataToQuery.companyId" :setCurrentName="{label:dataToQuery.companyName,value:dataToQuery.companyId}"></cascader-dom>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label="行业分类：" prop="content" >
                        <Select class='' placeholder="请选择行业类别" type='text' v-model='dataToQuery.dipTypeArrays' multiple>
                            <Option v-for="item in dictMap['env-00005']" :value="item.codingCodeId" :key="item.codingCodeId">{{ item.codingName }}</Option>
                        </Select>
                    </FormItem>
                </Col>
                <Col span="8">
                    <Button @click="switchQuery(true)" class="ivu-btn-switch" type="text">展开∨</Button>
                    <Button @click="reset" class="ivu-btn-reset">重置</Button>
                    <Button type="primary" class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
                </Col>
            </Row>
            <Row v-show="switchFlag" class="query-form">
                <Col span="8">
                    <FormItem label="企业名称：" prop="belongOrgId">
                        <cascader-dom class="query-form-el" ref='queryOrgCascader1' @setOrgInfo='setQueryCompanyId' :orgTree="true"
                                      :currentOrgId="dataToQuery.companyId" :setCurrentName="{label:dataToQuery.companyName,value:dataToQuery.companyId}"></cascader-dom>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label="行业分类：" prop="content" >
                        <Select class="query-form-el"  placeholder="请选择行业类别" type='text' v-model='dataToQuery.dipTypeArrays' multiple>
                            <Option v-for="item in dictMap['env-00005']" :value="item.codingCodeId" :key="item.codingCodeId">{{ item.codingName }}</Option>
                        </Select>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label="管理类别：" prop="managementCategory" >
                        <Select class="query-form-el" placeholder="请选择管理类别" type='text' v-model='dataToQuery.managementCategoryArrays' multiple>
                            <Option v-for="item in dictMap['dsp-000001']" :value="item.codingCodeId" :key="item.codingCodeId">{{ item.codingName }}</Option>
                        </Select>
                    </FormItem>
                </Col>
            </Row>
            <Row v-show="switchFlag" class="query-form">
                <Col span="8">
                    <FormItem label="登记时间：" prop="content" >
                        <DatePicker class="query-form-el" v-model="dataToQuery.dateRange"  format="yyyy-MM-dd" type="daterange" placement="bottom-end" placeholder="请选择查询时间段"
                                    @on-change="onSelectQueryDateRange"></DatePicker>
                    </FormItem>
                </Col>
				 <Col span="8">
				    <FormItem label="有效期截至：">
						<!--<RadioGroup v-model="dataToQuery.radioDipEndDate" type="button" class="query-form-el">
						    <Radio :label="1" border>近一个月</Radio>
						</RadioGroup>-->
                        <DatePicker class="query-form-el" v-model="dataToQuery.dipEndDateRange" format="yyyy-MM-dd" type="daterange" placement="bottom-end" placeholder="请选择查询时间段"
                                    @on-change="onSelectQueryDipEndDateRange"></DatePicker>
                    </FormItem>
				</Col>
                <Col span="8">
                    <Button @click="switchQuery(false)" class="ivu-btn-switch" type="text">收起∧</Button>
                    <Button @click="reset" class="ivu-btn-reset">重置</Button>
                    <Button class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
                </Col>
            </Row>
            <Row class="query-form">
                <Col span="24">
                    <Button size="large" :loading="pageStatus.baseLoading" class="ivu-btn-add" icon="md-add"  @click="addInfo">新增</Button>
                </Col>
            </Row>
        </Form>
        <Table ref='table' :height="tableHeight"  no-data-text="没有查询到相关数据!" @on-selection-change = 'getSelectRows' :loading='pageStatus.loading || pageStatus.baseLoading'
               border :columns="columns1"  :data="dataTable" :row-class-name="rowClassName">
        </Table>
        <Row style="margin-right:10px;">
            <Col span="24" >
                <Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize" @on-change="pageChange" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray" show-total show-sizer show-elevator />
            </Col>
        </Row>
        <Modal  title="排污许可证登记" :transfer=false :mask-closable="false" v-model="dialogShow" v-if="dataToView && dialogShow" :width=800 :styles="{height:'600px'}"  class-name='limit-height-dialog' >
            <Row>
                <Col span="24">
                    <Form ref="dialogForm" :class="mode === 'view'?'modal-view-detail':'modal-form'" :show-message="false" :model="dataToView" :rules="mode === 'view'?{} :ruleCustom"  :label-position="mode === 'view'?'right':'top'" :label-width="mode === 'view'?160:null">
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="23">
                                <FormItem label='企业名称：' prop='companyId'>
                                    <div v-if="mode === 'view'">{{dataToView.companyName}}</div>
                                    <cascader-dom v-else ref='orgCascader' @setOrgInfo='setCompanyId' @setOrgname="setCompanyName" :orgTree="true" :currentOrgId = "dataToView.companyId" :setCurrentName="{label:dataToView.companyName,value:dataToView.companyId}" ></cascader-dom>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='所在地：' prop='companyAddress'>
                                    <div v-if="mode === 'view'">{{areaCodeToAreaName(dataToView.companyAddress)}}</div>
                                    <Cascader v-else :data="tempAreaTree" v-model="dataToView.companyAddressArr" change-on-select :transfer="true"
                                              :load-data="areaTreeLoadData" :render-format="labels=>labels.join('·')"  :clearable='false'
                                              @on-change="(value,selectedData)=>{$set(dataToView,'companyAddress',value.join(','))}"></Cascader>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='许可证编号：' prop='dipNum'>
                                    <div v-if="mode === 'view'">{{dataToView.dipNum}}</div>
                                    <Input v-else v-model='dataToView.dipNum' class="query-form-el"></Input>
                                </FormItem>
                            </Col>
                        </Row>
						<Row type="flex" justify="space-around" class="code-row-bg">
						    <Col span="11">
						        <FormItem label='企业经营状态：' prop='businessStatus'>
						            <div v-if="mode === 'view'">{{dataToView.businessStatus == '2' ? '停产退出' :'正常'}}</div>
						            <Select v-else class='' placeholder="请选择企业经营状态" type='text' v-model='dataToView.businessStatus' >
										<Option value="1">正常</Option>
										<Option value="2">停产退出</Option>
									</Select>
						        </FormItem>
						    </Col>
							<Col span="11" v-if="dataToView.businessStatus == '2'">
								<FormItem label='停产日期：' prop='stopProductionDate'>
									<div v-if="mode === 'view'">{{renderViewDate(dataToView.stopProductionDate)}}</div>
									<DatePicker v-else type="date" placeholder="请选择停产日期" class="query-form-el" v-model='dataToView.stopProductionDate'  placement="bottom-start"></DatePicker>
								</FormItem>
							</Col>
							<Col span="11" v-else></Col>
						</Row>
						<div v-if="dataToView.businessStatus != '2'">
							<Row type="flex" justify="space-around" class="code-row-bg">
								<Col span="11">
									<FormItem label='行业类别：' prop='dipType'>
										<div v-if="mode === 'view'">{{this.dictMap['env-00005'][dataToView.dipType].codingName}}</div>
										<Select v-else class='' placeholder="请选择行业类别" type='text' v-model='dataToView.dipType' >
											<Option v-for="item in dictMap['env-00005']" :value="item.codingCodeId" :key="item.codingCodeId">{{ item.codingName }}</Option>
										</Select>
									</FormItem>
								</Col>
								<Col span="11">
									<FormItem label='管理类别：' prop='managementCategory'>
										<div v-if="mode === 'view'">{{ this.dictMap['dsp-000001'][dataToView.managementCategory].codingName }}</div>
										<Select v-else class='' placeholder="请选择管理类别" type='text' v-model='dataToView.managementCategory' >
											<Option v-for="item in dictMap['dsp-000001']" :value="item.codingCodeId" :key="item.codingCodeId">{{ item.codingName }}</Option>
										</Select>
									</FormItem>
								</Col>
							</Row>
							<Row type="flex" justify="space-around" class="code-row-bg">
								<Col span="11">
									<FormItem label='有效期起始：' prop='dipStartDate'>
										<div v-if="mode === 'view'">{{renderViewDate(dataToView.dipStartDate)}}</div>
										<DatePicker v-else type="date" placeholder="请选择日期" class="query-form-el" v-model='dataToView.dipStartDate'  placement="bottom-start"></DatePicker>
									</FormItem>
								</Col>
								<Col span="11">
									<FormItem label='有效期截止：' prop='dipEndDate'>
										<div v-if="mode === 'view'">{{renderViewDate(dataToView.dipEndDate)}}</div>
										<DatePicker v-else type="date" placeholder="请选择日期" class="query-form-el" v-model='dataToView.dipEndDate' placement="bottom-start"></DatePicker>
									</FormItem>
								</Col>
							</Row>
	<!--                        <Row type="flex" justify="space-around" class="code-row-bg">-->
	<!--                            <Col span="11">-->
	<!--                                <FormItem label='发证日期：' prop='wellPlan'>-->
	<!--                                    <div v-if="mode === 'view'">{{renderViewDate(dataToView.getDipDate)}}</div>-->
	<!--                                    <DatePicker v-else type="date" placeholder="请选择日期" class="query-form-el" v-model='dataToView.getDipDate'  placement="top-start"></DatePicker>-->
	<!--                                </FormItem>-->
	<!--                            </Col>-->
	<!--                            <Col span="11">-->
	<!--                                <FormItem label='中华人民共和国生态环境部监制：' prop='wellPlan'>-->
	<!--                                    <div v-if="mode === 'view'">{{dataToView.ifEco == '1'?'是':'否'}}</div>-->
	<!--                                    <Select v-else v-model='dataToView.ifEco' class='query-form-el'>-->
	<!--                                        <Option  value="1">是</Option >-->
	<!--                                        <Option  value="0">否</Option >-->
	<!--                                    </Select>-->
	<!--                                </FormItem>-->
	<!--                            </Col>-->
	<!--                        </Row>-->
							<Row type="flex" justify="space-around" class="code-row-bg">
								<Col span="11">
									<FormItem label='颗粒物（吨）：' prop='pm'>
										<div v-if="mode === 'view'">{{ dataToView.pm }}</div>
										<InputNumber v-else class='w' placeholder="请填写颗粒物（吨）" :min="0" type='text' v-model='dataToView.pm'></InputNumber>
									</FormItem>
								</Col>
								<Col span="11">
									<FormItem label='氮氧化物（吨）：' prop='nox'>
										<div v-if="mode === 'view'">{{ dataToView.nox }}</div>
										<InputNumber v-else class='w' placeholder="请填写氮氧化物（吨）" :min="0" type='text' v-model='dataToView.nox'></InputNumber>
									</FormItem>
								</Col>
							</Row>
							<Row type="flex" justify="space-around" class="code-row-bg">
								<Col span="11">
									<FormItem label='二氧化硫（吨）：' prop='so'>
										<div v-if="mode === 'view'">{{ dataToView.so }}</div>
										<InputNumber v-else class='w' placeholder="请填写二氧化硫（吨）" :min="0" type='text' v-model='dataToView.so'></InputNumber>
									</FormItem>
								</Col>
								<Col span="11">
									<FormItem label='VOCS（吨）：' prop='vocs'>
										<div v-if="mode === 'view'">{{ dataToView.vocs }}</div>
										<InputNumber v-else class='w' placeholder="请填写VOCS（吨）" :min="0" type='text' v-model='dataToView.vocs'></InputNumber>
									</FormItem>
								</Col>
							</Row>
							<Row type="flex" justify="space-around" class="code-row-bg">
								<Col span="11">
									<FormItem label='COD（吨）：' prop='cod'>
										<div v-if="mode === 'view'">{{ dataToView.cod }}</div>
										<InputNumber v-else class='w' placeholder="请填写COD（吨）" :min="0" type='text' v-model='dataToView.cod'></InputNumber>
									</FormItem>
								</Col>
								<Col span="11">
									<FormItem label='其他：' prop='other'>
										<div v-if="mode === 'view'">{{ dataToView.other }}</div>
										<Input v-else type='text' v-model='dataToView.other' ></Input>
									</FormItem>
								</Col>
							</Row>
							<Row type="flex" justify="space-around" class="code-row-bg">
								<Col span="23">
									<FormItem v-if="mode === 'view'" label="附件：">
										<div v-show="dataToView.idFiles.length>0" v-for="(item,index) in dataToView.idFiles">
											<a @click="downloadFiles(item,index)"><span style="color: #3399ff;margin-left: 5px">{{ item.fileName }}</span></a>
											<Progress v-show="uploadListVisible[item.id]" :percent="uploadListPercent[index]"></Progress>
										</div>
									</FormItem>
									<FormItem v-else label="附件：" prop="idFiles">
										<div>
											<Upload ref="upload"
													:before-upload="(file) => { beforeUpload1(file, 'id', 'dspInfo') }"
													:show-upload-list="true"
													:max-size="10240"
													multiple
													type="drag"
													:action="fileUrl">
												<div style="padding: 10px">
													<Icon type="ios-cloud-upload" size="45" style="color: #3399ff"></Icon>
													<p>点击将文件拖拽到这里上传</p>
													<!--<span style="font-size:8px;color: #797a64">支持扩展名：.rar .zip .doc .docx .pdf...</span>-->
												</div>
											</Upload>
										</div>
										<div v-show="dataToView.idFiles.length>0" v-for="(item,index) in dataToView.idFiles"
											 :key='item'>
											<a @click="downloadFiles(item,index)">{{ item.fileName }}</a>
											<Button type="text" icon="md-trash" @click="removeFile1(item.id, 'id', 'dspInfo')" style="margin-left: 5px;margin-bottom: 3px"/>
											<Progress v-show="uploadListVisible[item.id]" :percent="uploadListPercent[index]"></Progress>
											<!--<Progress  v-show="filePercentVisible[index]" :percent="filePercent[index]"></Progress>-->
										</div>
									</FormItem>
								</Col>
							</Row>
						</div>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='登记人：' prop='registrant'>
                                    <div v-if="mode === 'view'">{{dataToView.createUserName}}</div>
                                    <Input v-else type='text' v-model='dataToView.createUserName' readonly></Input>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='登记时间：' prop='registTime'>
                                    <div v-if="mode === 'view'">{{renderViewDate(dataToView.createDate)}}</div>
                                    <DatePicker v-else type="date" placeholder="请选择日期" class="query-form-el" v-model='dataToView.createDate' readonly></DatePicker>
                                </FormItem>
                            </Col>
                        </Row>
						<Row type="flex" justify="space-around" class="code-row-bg">
							<Col span="11">
							<FormItem label='登记人电话：' prop='createMobile'>
								<div v-if="mode === 'view'">{{dataToView.createMobile}}</div>
                                <Input v-else type='text' v-model='dataToView.createMobile'></Input>
								<!--<Input v-if="mode === 'add'" type='text' v-model='dataToView.createMobile'></Input>-->
								<!--<Input v-if="mode === 'edit'" type='text' v-model='dataToView.createMobile' :readonly="this.currentUser.userId === dataToView.createUserId ? false : 'readonly'"></Input>-->
							</FormItem>
							</Col>
							<Col span="11">
							</Col>
						</Row>
                    </Form>
                </Col>
            </Row>
            <div slot="footer">
                <Button v-if="mode != 'view'" type="primary"  class='ivu-btn-save' @click="submit('dialogForm')" >确定</Button>
                <Button v-if="mode != 'view'" type="primary"  class='ivu-btn-cancel' @click="handleCancel" >取消</Button>
                <Button v-if="mode === 'view'" class='ivu-btn-save' @click="dialogShow=false">关闭</Button>
            </div>
        </Modal>
    </Layout>
</template>

<script>
    import {Api} from '@/api/index.js'
    import { mapState, mapGetters, mapActions } from 'vuex'
    var cascaderDom = () => import('@/components/cascader-dom.vue');
    import pageCommonFunction from '@/components/pageCommonFunction.js'
	import { sessionStorage } from '@/common/cacheUtils.js'
    export default {
        components:{
            cascaderDom
        },
        computed:{
            ...mapState('trhg', {
                areaMap: state => state.area.areaMap?state.area.areaMap:[],
                areaTreeMap: state => state.area.areaTreeMap?state.area.areaTreeMap:{},
            }),
            cityList(){
                var province = this.areaMap[this.dataToView.province]
                if (province && province.children){
                    return province.children
                }else{
                    return []
                }
            }
        },
        data(){
            return {
                ...this.createCommonDataField(),
                columns1: [
                    { title: '序号', width: 80, fixed: 'left', align: 'center', render: this.indexColumnsRender},
                    { key:'companyName',title: '企业名称', fixed: 'left', align: 'center', minWidth: 200},
                    { key: 'companyAddress', title: '所在地', align: 'center', width: 130, render: this.renderCellArea },
                    { key:'dipNum',title: '许可证编号',  align: 'center', width: 120 },
					 { key:'businessStatus',title: '企业经营状态',  align: 'center', width: 120,render:(h, params)=>{
					  return h('span',  params.row.businessStatus =='2' ? '停产退出' :'正常')
					 } },
					 { key:'stopProductionDate',title: '停产日期',  align: 'center', width: 100, render: this.renderCellDate },
     //                { key:'dipType',title: '行业类别',  align: 'center', width: 120 ,render:(h, params)=>{
					//   return h('span',  (this.dictMap['env-00005'] && this.dictMap['env-00005'][params.row.dipType].codingName))
					// }, },
                    { key:'dipStartDate',title: '有效期起始',  align: 'center', width: 120, render: this.renderCellDate },
                    { key:'dipEndDate',title: '有效期截止',  align: 'center' , width: 120, render: this.renderCellDate },
                    // { key:'getDipDate',title: '发证日期',  align: 'center', width: 120, render: this.renderCellDate  },
                    // { key:'ifEco',title: '中华人民共和国生态环境部监制',  align: 'center', width: 150 , render:(h, params) => {
                    //     return h('span', params.row[params.column.key] === '1'?'是':'否')
                    // }},
					// { key:'managementCategory',title: '管理类别',  align: 'center', width: 120,render:(h, params)=>{
					//   return h('span', this.dictMap['dsp-000001'] && this.dictMap['dsp-000001'][params.row.managementCategory].codingName)
					// }, },
					{ key:'pm',title: '颗粒物（吨）',  align: 'center', width: 100 },
					{ key:'nox',title: '氮氧化物（吨）',  align: 'center', width: 100 },
					{ key:'so',title: '二氧化硫（吨）',  align: 'center', width: 100 },
					{ key:'vocs',title: 'VOCS（吨）',  align: 'center', width: 100 },
					{ key:'cod',title: 'COD（吨）',  align: 'center', width: 100 },
					{ key:'other',title: '其他',  align: 'center', width: 100 },
                    { key:'createUserName',title: '登记人',  align: 'center', width: 120  },
                    { key:'createDate',title: '登记时间',  align: 'center', width: 120, render: this.renderCellDate },
                    { key:'updateDate',title: '最新更新时间',  align: 'center', width: 120, render: this.renderCellDate },
                    this.getActionColumns()
                ],
                ruleCustom : {
                    companyId: [ { required: true, message: '请填写企业名称', trigger: 'change' } ],
                    companyAddress: [ { required: true, message: '请填写所在地', trigger: 'change' } ],
					businessStatus: [ { required: true, message: '请填写企业经营状态', trigger: 'change' } ],
					managementCategory: [ { required: true, message: '请选择管理类别', trigger: 'change',}],
					stopProductionDate: [ {
					    validator: (rule, value, callback) => {
					        if (value == null || value == '' || value == undefined) {
					            callback(' ')
					        } else {
					            callback()
					        }
					    },
					    required: true,
					    trigger: 'change'
					}],
                    dipStartDate: [ {
                        validator: (rule, value, callback) => {
                            if (value == null || value == '' || value == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    dipEndDate: [{
                        validator: (rule, value, callback) => {
                            if (value == null || value == '' || value == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    dipNum: [ { required: true, message: '请填写颗粒物（吨）', trigger: 'change'}],
					createMobile: [{ pattern: /^((0\d{2,3}-\d{7,8})|(1[3675849]\d{9}))$/, required: true, message: '请填写填报人电话', trigger: 'change' }],
					dipType: [ { required: true, message: '请填写行业类别', trigger: 'change'}],
					 // pm: [ { required: true, message: '请填写颗粒物（吨）', trigger: 'change',type:'number'}],
					 // nox: [ { required: true, message: '请填写氮氧化物（吨）', trigger: 'change',type:'number'}],
					 // so: [ { required: true, message: '请填写二氧化硫（吨）', trigger: 'change',type:'number'}],
					 // vocs: [ { required: true, message: '请填写VOCS（吨）', trigger: 'change',type:'number'}],
					 // cod: [ { required: true, message: '请填写COD（吨）', trigger: 'change',type:'number'}],
					 // other: [ { required: true, message: '请填写其他', trigger: 'change',type:'number'}],
                },
                tableHeight:10,

				dictMap:{},
                // api
                queryUrl:Api.queryDspInfo,
                deleteUrl:Api.deleteDspInfo,
                bthDeleteUrl:Api.batchDeleteDspInfo,
                getUrl:Api.getDspInfo,
                updateUrl:Api.updateDspInfo,
                saveUrl:Api.saveDspInfo,
            }
        },
        async mounted() {
            this.setTableHeight();
            this.pageStatus.baseLoading = true
            await this.$store.dispatch('trhg/area/query', {scope:this}, { root: true })
			// 加载 行业类别 管理类别  数据字典
			await this.$http.get(Api.queryDictBycode+"env-00005,dsp-000001",{}).then((res)=>{
				// 数据字典 list 转 map，方便调用
				this.dictMap = {
					'env-00005':this.dictListToMap(res.data.data['env-00005']),
					'dsp-000001':this.dictListToMap(res.data.data['dsp-000001']),
				}
			}).catch(e => {
                this.$Message.error("数据字典获取失败")
            });
            this.pageStatus.baseLoading = false
            this.query();
            this.tempAreaTree = this.areaTreeMap['0']
        },
        methods:{
            ...pageCommonFunction,
            addInfo() {
                this.dataToView = (this.createEmptyDataToAdd instanceof Function) ? this.createEmptyDataToAdd() : {};
                this.dataToView.companyId = this.currentUser.companyId;
                this.dataToView.companyName = this.currentUser.companyName;
                this.dataToView.belongOrgId = this.currentUser.twoLevelOrgId;
                this.dataToView.belongOrgName = this.currentUser.twoLevelOrgName;
                this.dataToView.registrant = this.currentUser.userName;
                this.dataToView.registrantPhone = this.currentUser.mobileNumber;
                this.dataToView.registTime = new Date();
                this.dataToView.createUserId = this.currentUser.userId;
                this.dataToView.createUserName = this.currentUser.userName;
                this.dataToView.createDate = new Date();
                this.mode = 'add';
                this.dialogShow = true;       
            },
            beforeEditDialogOpen(data){
                if(data.row.companyAddress){
                    data.row.companyAddressArr = data.row.companyAddress.split(',')
                    data.row.companyAddressName = this.areaCodeToAreaName(data.row.companyAddress)
                }
            },
            async afterDataToViewInit(data) {
                if (data && data.companyAddress) {
                    let companyAddressArr = data.companyAddress.split(',')
                    this.tempAreaTree = []
                    setTimeout(() => {
                        this.tempAreaTree = this.addressEditArr(this.areaTreeMap,companyAddressArr)
                    }, 100)
                }
                await this.getFiles1('id', 'dspInfo')
            },
            deleteData(params) {
                this.deleteDateAjax(params);
            },
            query() {
                if(this.dataToQuery.dipTypeArrays) {
                    this.dataToQuery.dipTypes = this.arrayToInFormat(this.dataToQuery.dipTypeArrays)
                }
                if(this.dataToQuery.managementCategoryArrays) {
                    this.dataToQuery.managementCategories = this.arrayToInFormat(this.dataToQuery.managementCategoryArrays)
                }
				this.dataToQuery.radioDipEndDate = new Date();
				this.dataToQuery.radioDipStartDate = new Date();
				this.dataToQuery.radioDipStartDate.setTime(this.dataToQuery.radioDipStartDate.getTime() - 3600 * 1000 * 24 * 30);
				this.dataToQuery.radioDipEndDate = this.getNowDate(this.dataToQuery.radioDipEndDate)
				console.log(this.dataToQuery)
                this.queryAjax();
            },
            submit(name) {
				if (this.dataToView.businessStatus == '2') {
					this.dataToView.pm= 0,
					this.dataToView.nox=  0,
					this.dataToView.so= 0,
					this.dataToView.vocs= 0,
					this.dataToView.cod= 0,
					this.dataToView.other=''
					this.dataToView.managementCategory=null
					this.dataToView.dipType=null
					this.dataToView.dipStartDate=null
					this.dataToView.dipEndDate=null
				} else {
					this.dataToView.stopProductionDate =null
				}
                this.$set(this.dataToView,'companyAddress',this.dataToView.companyAddressArr.join(','))
                this.submitAjax(name);
            },
            createEmptyDataToAdd(){
                return {
                    registrant: this.currentUser.userName,
                    registTime: new Date(),
				    pm: null,
				    nox:  null,
				    so: null,
				    vocs: null,
				    cod: null,
				    other: null,
				    companyAddressArr:[],
					createMobile: sessionStorage('userId').getObject('userId').mobileNumber,
                    id: this.get_uuid(),
                    idFiles: [],
			    }
			},
			rowClassName(row,index){
				if(row.markedRed=='1'){
					return 'table-row-red';
				}else if (row.markedRed=='0'){
                    return 'table-row-yellow';
                }
			},
            onSelectQueryDipEndDateRange(data) {
                if (data[0] === "" || data[1] === "") {
                    this.dataToQuery.dipEndDateStart = null;
                    this.dataToQuery.dipEndDateEnd = null;
                } else {
                    console.log(data);
                    this.dataToQuery.dipEndDateStart = data[0] + ' 00:00:00';
                    this.dataToQuery.dipEndDateEnd = data[1] + ' 23:59:59';
                }
            },
			getNowDate(fm){
			    // var date = new Date()
			    var year = fm.getFullYear()
			    var month = fm.getMonth()
			    var day = fm.getDate()
			    //月份需要+1，因为月份获取的是0-11
			    return `${year}-${(month+1).toString().padStart(2, '0')}-${day.toString().padStart(2, '0')}`
			}
        },
        watch:{
        },

    }
</script>

<style lang='css' >
	.ivu-table-tbody .table-row-yellow td{
		background-color: #fff9c4 !important;
	}
    .ivu-table-tbody .table-row-red td{
        background-color: #fedede !important;
    }
</style>
